<?php
/**
 * 返回博客分类
 * User: YuanXi
 * Date: 2021/6/10 0010
 * Time: 14:50
 */
if (! function_exists('categories')) {
    function categories(){
        // //缓存操作
        $categories = cache()->rememberForever('categories',function (){
            //查询数据库
            $categories = \Illuminate\Support\Facades\DB::table('categories')
                ->pluck('name','id');
            return $categories;
        });
        return $categories;
    }
}

/**
 * 返回头像地址
 */
if (! function_exists('avatar')) {
    function avatar($avatar){
        $avatar_url = $avatar ? asset('storage/' . $avatar) : asset('img/default/avatar.jpg');
        return $avatar_url;
    }
}
